'use strict';

/**
 * 名片 - 数据模型
 * **/

module.exports = app => {
  const mongoose = app.mongoose;

  const cardSchema = new mongoose.Schema({
    avatarUrl: {
      type: String,
      displayName: '头像',
      required: true,
    },
    openId: {
      type: String,
      displayName: 'openId',
      required: true,
    },
    unionId: {
      type: String,
      displayName: 'unionId',
      //required: true,
    },
    gender: {
      type: Number,
      displayName: '性别',
      required: true,
    },
    nickName: {
      type: String,
      displayName: '昵称',
      required: true,
    },
    name: {
      type: String,
      displayName: '姓名',
      required: true,
    },
    phone: {
      type: String,
      displayName: '电话',
      required: true,
    },
    industry: {
      type: String,
      displayName: '行业',
      required: true,
    },
    company: {
      type: String,
      displayName: '公司',
    },
    position: {
      type: String,
      displayName: '职位',
    },
    wechat: {
      type: String,
      displayName: '微信号',
    },
    address: {
      province: {
        type: String,
        displayName: '省',
      },
      city: {
        type: String,
        displayName: '市',
      },
      // district '区'
      area: {
        type: String,
        displayName: '区',
      },
      detail: {
        type: String,
        displayName: '详细地址',
      },
      latitude: {
        type: String,
        displayName: '经度',
      },
      longitude: {
        type: String,
        displayName: '纬度',
      },
    },
    introduce: {
      type: String,
      displayName: '个人简介',
      required: true,
    },
    business: [{
      name: {
        type: String,
        displayName: '业务名',
      },
      intro: {
        type: String,
        displayName: '业务介绍',
      },
      showImg: [{
        type: String,
        displayName: '展示图片',
      }],
    }],
    check: [{
      type: String,
      displayName: '查看人的id',
    }],
    favorite: [{
      type: String,
      displayName: '收藏人的id',
    }],
    like: [{
      type: String,
      displayName: '点赞人的id',
    }],
  });

  return mongoose.model('card', cardSchema);
};
